/// 用户角色枚举
enum UserRole {
  /// 超级管理员
  superAdmin('super_admin'),
  
  /// 管理员
  admin('admin'),
  
  /// 操作员
  operator('operator'),
  
  /// 普通用户
  user('user'),
  
  /// 游客
  guest('guest');
  
  /// 角色代码
  final String code;
  
  const UserRole(this.code);
  
  /// 从字符串转换为枚举
  static UserRole fromString(String value) {
    return UserRole.values.firstWhere(
      (role) => role.code == value,
      orElse: () => UserRole.user,
    );
  }
  
  /// 检查是否为管理员
  bool get isAdmin => this == UserRole.admin || this == UserRole.superAdmin;
  
  /// 检查是否为超级管理员
  bool get isSuperAdmin => this == UserRole.superAdmin;
  
  /// 检查是否为操作员
  bool get isOperator => this == UserRole.operator;
  
  /// 检查是否为普通用户
  bool get isUser => this == UserRole.user;
  
  /// 检查是否为游客
  bool get isGuest => this == UserRole.guest;
} 